package com.lhoverc.controller.admin;

import com.lhoverc.pojo.PageBean;
import com.lhoverc.pojo.Result;
import com.lhoverc.pojo.VO.ApplyDataVO;
import com.lhoverc.pojo.entity.ApplyEntity;
import com.lhoverc.service.apply.ApplyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author: LiCheng
 * @CreateTime: 2025-04-16
 * @Description:
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/admin/apply")
public class AdminApplyController {
    @Autowired
    private ApplyService applyService;

    /**
     * 获取今天所有的申请
     *
     * @return
     */
    @GetMapping("getAllTodayApply")
    public Result getAllTodayApply() {
        List<ApplyDataVO> applyDataVOList = applyService.getAllTodayApply();
        return Result.success(applyDataVOList);
    }

    /**
     * 获取所有符合条件的申请
     *
     * @return
     */
    @GetMapping("/getAllApply")
    public Result getAllApply(String searchKeyword,
                              Integer statusKeyword,
                              @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
                              @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime,
                              @RequestParam(defaultValue = "1") Integer page,
                              @RequestParam(defaultValue = "20") Integer pageSize) {
        PageBean pageBean = applyService.getAllApply(searchKeyword, statusKeyword, startTime, endTime, page, pageSize);
        return Result.success(pageBean);
    }

    @GetMapping("/getApply")
    public Result getApply(){
        List<ApplyEntity> applyEntityList = applyService.getApply();
        return Result.success(applyEntityList);
    }
}
